package com.jf.yytgd.converter;

import com.jf.yytgd.entity.bean.Comment;
import com.jf.yytgd.entity.bean.Diary;
import com.jf.yytgd.entity.bean.User;
import com.jf.yytgd.entity.dto.combined.ChildCommentUserDTO;
import com.jf.yytgd.entity.dto.combined.CommentUserDTO;
import com.jf.yytgd.entity.dto.combined.DiaryUserBarDTO;
import com.jf.yytgd.entity.dto.combined.DiaryUserDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * Created with IntelliJ IDEA
 * Description: 组合转换器
 * User:22954
 * Date:2025-02-07
 * Time:0:27
 */
@Mapper
public interface CombinedConverter {
    CombinedConverter INSTANCE = Mappers.getMapper(CombinedConverter.class);

    @Mapping(source = "diary.id", target = "diaryId")
    @Mapping(source = "user.id", target = "userId")
    DiaryUserDTO toDiaryUserDTO(Diary diary, User user);

    @Mapping(source = "diary.id", target = "diaryId")
    @Mapping(source = "user.id", target = "userId")
    DiaryUserBarDTO toDiaryUserBarDTO(Diary diary, User user);

    @Mapping(source = "comment.id", target = "commentId")
    @Mapping(source = "comment.createdAt", target = "createdAt")
    @Mapping(source = "user.id", target = "userId")
    CommentUserDTO toCommentUserDTO(Comment comment, User user);

    @Mapping(source = "comment.id", target = "commentId")
    @Mapping(source = "comment.createdAt", target = "createdAt")
    @Mapping(source = "user.id", target = "userId")
    @Mapping(source = "user.nickname", target = "nickname")
    @Mapping(source = "user.portraitPath", target = "portraitPath")
    @Mapping(source = "father.id", target = "fatherId")
    @Mapping(source = "father.nickname", target = "fatherNickname")
    ChildCommentUserDTO toChildCommentUserDTO(Comment comment, User user, User father);
}
